package com.lmonkey.servlet.forget;

import com.lmonkey.servic.USERDao;
import com.lmonkey.shop.USER;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/shangc/forgetcheck")
public class ForgetCheck extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        //获取数据
        String date = request.getParameter("date");
        //数据库中查询
        USER u = USERDao.selectByeamil(date);
        if (u == null){
            PrintWriter out = response.getWriter();
            out.println("<script>alert('输入邮箱或者昵称不正确');location.href='forget.jsp';</script>");
            out.close();
            return;
        }else
        {
            String num = "2";
            request.setAttribute("u",u);
            request.setAttribute("num",num);
            request.getRequestDispatcher("forget.jsp").forward(request,response);
        }
    }
}
